// 视频源替代脚本
document.addEventListener('DOMContentLoaded', function() {
    // 创建新的视频元素
    var video = document.createElement("video");
    video.src = "https://mazwai.com/videvo_files/video/free/2016-11/small_watermarked/Aloha_Spirit-Joris_Marengo_TravelerOnTheRoad.com_preview.webm";
    video.autoplay = false;
    video.controls = true;
    video.poster = "https://images.pexels.com/photos/7876708/pexels-photo-7876708.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1";
    
    // 添加视频源
    var source = document.createElement("source");
    source.src = "https://mazwai.com/videvo_files/video/free/2016-11/small_watermarked/Aloha_Spirit-Joris_Marengo_TravelerOnTheRoad.com_preview.webm";
    source.type = "video/webm";
    
    // 添加备用视频源
    var sourceMp4 = document.createElement("source");
    sourceMp4.src = "https://cdn.videvo.net/videvo_files/video/free/2019-01/small_watermarked/181015_13_Venice%20Beach%20Drone_25_preview.mp4";
    sourceMp4.type = "video/mp4";
    
    // 添加提示信息
    var fallbackMsg = document.createElement("p");
    fallbackMsg.textContent = "您的浏览器不支持视频播放，请升级您的浏览器。";
    fallbackMsg.style.color = "white";
    fallbackMsg.style.textAlign = "center";
    fallbackMsg.style.padding = "20px";
    
    // 组合视频元素
    video.appendChild(source);
    video.appendChild(sourceMp4);
    video.appendChild(fallbackMsg);
    
    // 替换原视频元素
    var introVideo = document.getElementById("introVideo");
    if (introVideo) {
        var videoContainer = introVideo.parentNode;
        videoContainer.replaceChild(video, introVideo);
        video.id = "introVideo";
    }
    
    // 错误处理
    video.addEventListener('error', function(e) {
        console.error('视频加载错误:', e);
        // 如果视频加载失败，显示错误信息
        var errorMsg = document.createElement("div");
        errorMsg.innerHTML = `
            <div style="padding: 30px; text-align: center; background-color: #000;">
                <i class="bi bi-exclamation-triangle" style="font-size: 48px; color: #ff5c5c; margin-bottom: 15px;"></i>
                <p style="color: white; font-size: 16px;">视频加载失败，请检查网络连接或稍后再试。</p>
            </div>
        `;
        videoContainer.innerHTML = '';
        videoContainer.appendChild(errorMsg);
    });
}); 